-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add conversion api #89
Conversation
Edit: deprecated Python 3.6 support in #100 |
4fb4b2d
to
a7313bd
Compare
2c4e445
to
a80a3d6
Compare
a80a3d6
to
88f7dc3
Compare
90cc548
to
1d23f82
Compare
I was trying to verify it but I got the following error:
|
I put a breakpoint at 83:
|
|
I swapped the order of the two, does it work now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fubuloubu no i think it has to be int
not "uint256"
I swapped the order of the two, does it work now?
In [1]: convert("1 Eth","int") == int(1e18)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-1-0c519f26f9f1> in <module>
----> 1 convert("1 Eth","int") == int(1e18)
~/work/apeworx/ape/src/ape/managers/converters.py in convert(self, value, type)
83 if type not in self._converters:
84 converter_types = ", ".join(map(lambda t: t.__name__, self._converters))
---> 85 raise Exception(f"ABI Type '{type}' must be one of [{converter_types}]")
86
87 if self.is_type(value, type):
Exception: ABI Type 'int' must be one of [ChecksumAddress, bytes, int]
unit=st.sampled_from(list(ETHER_UNITS.keys())), | ||
) | ||
def test_ether_conversions(value, unit): | ||
assert convert(value=f"{value} {unit}", type=int) == int(value * ETHER_UNITS[unit]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test looks right, and passes
@fubuloubu ok looks good to me as long as those caveats I listed above - to use syntax needs to be like |
* feat: add non-checksummed address converter (with warning) * refactor: use internal AddressType instead of ChecksumAddress * feat: add AddressAPI converter to address * refactor: add conversion manager dep to account manager * refactor: display accounts in repr * feat: added support for ether types in account calls * test: add tests for ether conversion fn * feat: add conversion for Ether units * feat: add ConversionAPI * fix: updates eth-account requirement in setup.py to fix breaking change from pull 103 (#107) Co-authored-by: Doggo <[email protected]>
What I did
Added support for argument conversions via API
fixes: #3
depends: #92How I did it
Added
ConversionManager
andConverterAPI
How to verify it
(In
ape console
):Checklist